﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;


namespace VRP_SM
{
    class ProgramEntry
    {
        static void Main(string[] args)
        {
            Stopwatch timer = new Stopwatch();                                                      // get running time
            timer.Start();                                                                          // start to calculate time               

            string inputFile;

            // If there are command line arguments, the first one is the file name
            if (args.Length != 0)
                inputFile = args[0];
            else
                inputFile = "Example1.vrp";

            // Create the parser object, and read in all the data from file. This object can read ANY TSPLIB file. Code borrowed from HeuristicLab.
            TSPLIBParser myParser = new TSPLIBParser(inputFile);
            myParser.Parse();

            // Create the vrp data object, using the parsed data
            CVRPData vrpData = new CVRPData(myParser);

            // Run the savings method heuristic
            CVRPSolution mySolution = Heuristics.SavingsMethod(vrpData);

            timer.Stop();                                                                   // stop to calculate run time
            TimeSpan totalTime = timer.Elapsed;                                             // get the elapsed time as a TimeSpan value

            // Check if the solution is feasible
            mySolution.CheckFeasibility(vrpData);

            // Output the solution
            mySolution.WriteToFile(inputFile + ".opt", totalTime);
            
        }

    }
}
